package question14;
//有一个String[]数组如下：
//String[] nums = {“3.22”,”8.1”,”7”,”2.5”,”3.1”,”7.77”,”8.0”,”9.21”}
//请编程计算它们的平均值，结果精确到小数点后两位。

import java.math.BigDecimal;

public class BigDecimalDemo {
    public static void main(String[] args) {
        String[] nums = {"3.22","8.1","7","2.5","3.1","7.77","8.0","9.21"};
        BigDecimal decimal1 = new BigDecimal(nums.length);
        long sum=0L;
        for (String num : nums) {
            sum+=Double.parseDouble(num);
        }
        BigDecimal decimal2 = new BigDecimal(sum);
        System.out.println(decimal2.divide(decimal1,2,BigDecimal.ROUND_HALF_UP));
    }
}
